<template>
	<view class="page">
		<!-- 搜索 -->
		<view class="search flex-row-start">
			<image src="../../static/search_b.png"></image>
			<input class="input_search" placeholder="搜索药品" maxlength="30" @input="Onsech" placeholder-class="placeholderClass" />
		</view>
		<!-- 列表 -->
		<view class="drugs-list">
			<LoadMore ref="LoadMore" id="LoadMore" :diffHeight="102" :initData="initData" @dataRefresh='dataRefresh'>
				<block v-for="(item, index) in dataList" :key="index">
					<view class="item flex-row-between" @click="goNext('/pagesA/prescript/drugDetail?id=' + item.goods_id)">
						<view class="left bg-cover"  :style="{backgroundImage: 'url(' + item.logo + ')'}"></view>
						<view class="right">
							<view class="p1 font14">{{item.goods_name}}</view>
							<view class="p2 font12 font-969696">{{item.manufacturer ? item.manufacturer : '暂无厂商'}}</view>
							<view class="p3 font14 font-ff4646">￥{{item.spec_info.goods_price}}</view>
						</view>
						<view class="btn-small green" @click.stop="goNext('/pagesA/prescript/drugsEdit?mode=add&id=' + item.goods_id)">加入处方</view>
					</view>
				</block>
			</LoadMore>
		</view>
	</view>
</template>

<script>
	import LoadMore from "@/components/loadMore.vue";
	export default {
		components: { LoadMore },
		data() {
			return {
				//传参数据
				initData: {
					url: 'goodsList',
					param: {
						business_id: 0,
						name: ''
					},
				},
				dataList:[],
			}
		},
		onLoad(options){
			if(options.business_id) this.initData.param.business_id = options.business_id
		},
		methods: {
			//input筛选
			Onsech(e) {
				this.initData.param.name = e.detail.value
				this.$refs.LoadMore.oncutRefresh(this.initData)
			},
			//返回数据
			dataRefresh(e) {
				e.forEach(item => {
					item.logo = this.$store.state.http_img + item.logo
				})
				this.dataList = e
			},
			goNext (url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style lang="less">
	@import url("style.less");
</style>
